import request from '@/utils/request';

// 用户登录接口 
export const login = (username, password) => {
    return request.post('/user/login', {
        username,
        password
    })
}

// 用户注册接口 
export const register = (username, password, types, email = null) => {
    return request.post('/user/register', {
        username,
        password,
        types,
        email
    })
}

// 用户注销接口 
export const deleteUser = (userid) => {
    return request.delete(`/user/deleteuser/${userid}`)
}

// 用户更新个人信息接口
export const updateUserInfo = (data) => {
    return request.put('/user/updateUser', data)
}

// 用户修改密码接口
export const changeUserPassword = (userId, oldPassword, newPassword) => {
    return request.put('/user/updatePassword', {
        userId,
        oldPassword,
        newPassword
    })
}

// 用户上传图片接口
export const uploadUserImg = (userid, formData) => {
    return request.post('/user/upload', formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        params: {
            userid
        }
    })
}

// 用户查看自己所有帖子的接口
export const getMyAllPosts = (userid) => {
    return request.get(`/user/allPosts?userid=${userid}`)
}

// 志愿者进入社区页面获取所有盲人所发的帖子
export const getBlindPosts = () => {
    return request.get('/user/blindPosts')
}

// 志愿者发表评论接口
export const addComment = (data) => {
    return request.post('/user/postComment', data)
}

// 根据 postsId 获取帖子的评论
export const getPostComments = (postsId) => {
    return request.get(`/user/postComments?postsId=${postsId}`)
}

// 盲人注册
export const blindRegister = () => {
    return request.get('/user/blindRegister', {
    })
}

// 举报接口
export const reportPost = (data) => {
    return request.post('/user/reportPost', data)
}

// 用户反馈接口
export const userFeedback = (data) => {
    return request.post('/user/feedback', data)
}